﻿
namespace KochamPycze.Model
{
    class Note
    {
        public enum Color { None=0, Black=1, Red=2, Green=3, Blue=4 }

        private static readonly int[] positions = { 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6 };
        private static readonly bool[] has_sharp = { false, false, true, false, true, false, false, true, false, true, false, true };
        private static readonly string[] names = { "B", "C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯" };
        private static readonly int octave_semitones = 12;
        private static readonly int octave_positions = 7;

        public readonly int value;
        public readonly int position;
        public readonly bool sharp;
        public readonly Color color;
        public readonly string name;

        public Note(int value, Color color)
        {
            this.value = value;
            this.color = color;
            int octave = value / octave_semitones;
            int mark = value % octave_semitones;
            position = octave_positions * octave + positions[mark];
            sharp = has_sharp[mark];
            name = names[mark];
        }
    }
}
